﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _7.Exercise
{
    class Program
    {
        private static StringBuilder EncriptingDecripting(string key, string text)
        {
            StringBuilder newtext = new StringBuilder(text.Length);
            for (int i = 0; i < text.Length; i++)
            {
                int k = 0;
                if (k == key.Length)
                {
                    k = 0;
                }
                newtext.Append((char)(key[k] ^ text[i]));
                k++;
            }
            return newtext;
        }
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;
            string key = "ABASAKDD";
            string text="ASFAFFFDLFJKLSFJOPAU";
            StringBuilder encripttext = EncriptingDecripting(key, text);
            Console.WriteLine(encripttext);
            StringBuilder decriptText = EncriptingDecripting(key, encripttext.ToString());
            Console.WriteLine(decriptText);
        }

        
    }
}
